package com.lanqiao.cloud.product.controller;

import com.lanqiao.springcloud.domain.Product;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 王文凯
 * 未来的生活很潇洒
 * 未来的世界很自由
 */
@RestController
@RequestMapping("/api/products/")
public class ProductController {
    List<Product> productList = new ArrayList<>();
    Product product1 =new Product("001","vivo x80",3999.0);
    Product product2 =new Product("002","iqoo9",3356.0);
    Product product3 =new Product("003","redmi k50",2500.0);

    @Value("${eureka.instance.hostname}")
    private String host;

    @RequestMapping("/")
    public List<Product> getProductList(){
        System.out.println("请求的端口在这："+host);
        productList.add(product1);
        productList.add(product2);
        productList.add(product3);
        return productList;
    }
}
